package br.ufmg.dcc.vod.remoteworkers.registry;

import java.rmi.AccessException;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RemoteRegistry {

	private final Registry remoteRegistry;

	public RemoteRegistry(String host, int port) throws RemoteException {
		remoteRegistry = LocateRegistry.getRegistry(host, port);
	}

	public <T extends Remote> T lookup(String objectName, Class<T> clazz) throws AccessException, RemoteException, NotBoundException {
		return clazz.cast(remoteRegistry.lookup(objectName));
	}
	
	public String[] list() throws AccessException, RemoteException {
		return remoteRegistry.list();
	}
}